﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Data.Common;
using System.Collections;
using System.Collections.ObjectModel;
using Portal.Workflow.Model;
using Portal.Workflow.Utilities;
using Portal.Workflow.Library;
using Portal.Web.Model;
using Portal.Core;
using Portal.Web.Utility;
using Portal.Utility;

namespace Portal.Workflow.Bussiness
{
    public class UserAjaxWorkflowTaskNextLink
    {
        string SessionId = System.Guid.NewGuid().ToString();
        
        public void RegiterAjaxPro()
        {
            AjaxPro.Utility.RegisterTypeForAjax(typeof(UserAjaxWorkflowTaskNextLink));
        }


        public static string GetAjaxProNextLinkJavascript(string SiteId,string ContentWorkflow,string DivMainForm)
        {
            string JavascriptText =
                "<script language=\"javascript\">\r\n" +

                "    function ClientShowOriginDocument(WorkflowActionId)\r\n" +
                "    {\r\n" +
                "        SiteId='"+SiteId+"';\r\n"+
                "        Url=Portal.Workflow.Bussiness.UserAjaxWorkflowTaskNextLink.ServerSideGetOriginUrl(SiteId,  WorkflowActionId).value;\r\n" +
                "        if(Url.indexOf('ERROR')!=-1)\r\n" +
                "        {\r\n" +
                "            alert(Url);\r\n" +
                "            return;\r\n" +
                "        }\r\n" +
                "        window.open(Url,'_self');\r\n" +
                "    }\r\n" +

                "   function ClientUploadFile(ParentControlId,SessionId)\r\n" +
                "   {\r\n" +
                "       SiteId='" + SiteId + "';\r\n" +
                "       Url=Portal.Workflow.Bussiness.UserAjaxWorkflowTaskNextLink.ServerSideGetUploadFileUrl(SiteId, ParentControlId,SessionId).value;\r\n" +
                "       window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 140px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');\r\n" +
                "       rValue=Portal.Workflow.Bussiness.UserAjaxWorkflowTaskNextLink.DrawAttachInfo(SiteId, SessionId).value;\r\n" +
                "       document.getElementById(\"divFileAttachInfo\").innerHTML=rValue;\r\n" +
                "   }\r\n" +

                "   function ClientRemoveFile(SessionId,FileName)\r\n" +
                "   {\r\n" +
                "       SiteId='" + SiteId + "';\r\n" +
                "       ConfirmMsg=Portal.Workflow.Bussiness.UserAjaxWorkflowTaskNextLink.GetConfirmMsg(SiteId).value;\r\n" +
                "       if(confirm(ConfirmMsg)==false)return;\r\n" +

                "       rValue=Portal.Workflow.Bussiness.UserAjaxWorkflowTaskNextLink.ServerSideRemoveFile(SiteId, SessionId,FileName).value;\r\n" +
                "       alert(rValue);\r\n" +

                "       rValue=Portal.Workflow.Bussiness.UserAjaxWorkflowTaskNextLink.DrawAttachInfo(SiteId, SessionId).value;\r\n" +
                "       document.getElementById(\"divFileAttachInfo\").innerHTML=rValue;\r\n" +
                "   }\r\n" +

                "   function ClientSelectNextLink(WorkflowDefId,WorkflowActionId,RecordId)\r\n" +
                "   {\r\n" +
                "       SiteId='" + SiteId + "';\r\n" +
                "       ExtraInfo=document.getElementById(\"txtExtraInfo\").value;\r\n" +
                "       LinkIndex=document.getElementById(\"drpSelectLink\").selectedIndex;\r\n" +
                "       if(LinkIndex<=0)\r\n" +
                "       {\r\n" +
                //"           alert('Xin vui lòng chọn đường xử lý');\r\n" +
                "           document.getElementById('divContentWorkflowProcess').innerHTML='Xin chọn đường xử lý';\r\n"+
                "           return;\r\n" +
                "       }\r\n" +
                "       LinkId=document.getElementById(\"drpSelectLink\").options[LinkIndex].value;\r\n" +
                "       oReturnParam=Portal.Workflow.Bussiness.UserAjaxWorkflowTaskNextLink.ServerSideGetLinkUrl(SiteId, WorkflowDefId,WorkflowActionId, RecordId, ExtraInfo, LinkId).value;\r\n" +
                "       if(oReturnParam.IsLink)\r\n" +
                "       {\r\n"+
                "           document.getElementById('divContentWorkflowProcess').innerHTML=oReturnParam.HtmlContent;\r\n" +
                "       }\r\n"+
                "       else\r\n"+
                "       {\r\n"+
                "           document.getElementById('"+ContentWorkflow+"').innerHTML=oReturnParam.HtmlContent;\r\n" +
                "       }\r\n"+
                "   }\r\n" +
                
                "  function ClientGetSendUser(ParentId)\r\n" +
                "  {\r\n" +
                "        SiteId='" + SiteId + "';\r\n" +
                "        WorkflowActionId=document.getElementById(\"txtWorkflowActionId\").value;\r\n" +
                "        WorkflowDefId=document.getElementById(\"txtWorkflowDefId\").value;\r\n" +
                "        LinkIndex=document.getElementById(\"drpSelectLink\").selectedIndex;\r\n" +
                "        if(LinkIndex<=0)\r\n" +
                "        {\r\n" +
                "            alert('Xin vui lòng chọn đường xử lý');\r\n" +
                "            return;\r\n" +
                "        }\r\n" +
                "        LinkId=document.getElementById(\"drpSelectLink\").options[LinkIndex].value;\r\n" +
                "        RecordId=document.getElementById(\"txtRecordId\").value;\r\n" +
                "        Url=Portal.Workflow.Bussiness.UserAjaxWorkflowTaskNextLink.ServerSideGetSendUserUrl(SiteId,WorkflowDefId, WorkflowActionId, RecordId, LinkId, ParentId).value;\r\n" +
                "        if(Url.indexOf('ERROR')!=-1)\r\n" +
                "        {\r\n" +
                "            alert(Url);\r\n" +
                "            return;\r\n" +
                "        }\r\n" +
                "        window.open(Url,'_blank');\r\n" +
                "  }\r\n" +


                "  function ClientDetectResponsible(ParentId,ParentIdText)\r\n" +
                "  {\r\n" +
                "        SiteId='" + SiteId + "';\r\n" +
                "        Url=Portal.Workflow.Bussiness.UserAjaxWorkflowTaskNextLink.ServerSideSelectResponsible(SiteId, ParentId, ParentIdText).value;\r\n" +
                "        if(Url.indexOf('ERROR')!=-1)\r\n" +
                "        {\r\n" +
                "            alert(Url);\r\n" +
                "            return;\r\n" +
                "        }\r\n" +
                "        window.open(Url,'_blank');\r\n" +
                "  }\r\n" +

                "  function ClientGetViewUser(ParentId)\r\n" +
                "  {\r\n" +
                "        SiteId='" + SiteId + "';\r\n" +
                "        WorkflowActionId=document.getElementById(\"txtWorkflowActionId\").value;\r\n" +
                "        WorkflowDefId=document.getElementById(\"txtWorkflowDefId\").value;\r\n" +
                "        LinkIndex=document.getElementById(\"drpSelectLink\").selectedIndex;\r\n" +
                "        if(LinkIndex<=0)\r\n" +
                "        {\r\n" +
                "            alert('Xin vui lòng chọn đường xử lý');\r\n" +
                "            return;\r\n" +
                "        }\r\n" +
                "        LinkId=document.getElementById(\"drpSelectLink\").options[LinkIndex].value;\r\n" +
                "        RecordId=document.getElementById(\"txtRecordId\").value;\r\n" +
                "        Url=Portal.Workflow.Bussiness.UserAjaxWorkflowTaskNextLink.ServerSideGetViewUserUrl(SiteId,WorkflowDefId, WorkflowActionId, RecordId, LinkId, ParentId).value;\r\n" +
                "        if(Url.indexOf('ERROR')!=-1)\r\n" +
                "        {\r\n" +
                "            alert(Url);\r\n" +
                "            return;\r\n" +
                "        }\r\n" +
                "        window.open(Url,'_blank');\r\n" +
                "  }\r\n" +

                "   function ClientCancelDoNextLink()\r\n"+
                "   {\r\n"+
                "       document.getElementById('"+ContentWorkflow+"').style.display=\"none\";\r\n"+
                "       document.getElementById('"+DivMainForm+"').style.display=\"block\";\r\n"+
                "   }\r\n"+

                "    function ClientDoNextLink(){\r\n" +
                "        SiteId='" + SiteId + "';\r\n" +
                "        LinkIndex=document.getElementById(\"drpSelectLink\").selectedIndex;\r\n" +
                "        if(LinkIndex<=0)\r\n" +
                "        {\r\n" +
                "            alert('Xin vui lòng chọn đường xử lý');\r\n" +
                "            return;\r\n" +
                "        }\r\n" +
                "        LinkId=document.getElementById(\"drpSelectLink\").options[LinkIndex].value;\r\n" +
                "        WorkflowActionId=document.getElementById(\"txtWorkflowActionId\").value;\r\n" +
                "        WorkflowDefId=document.getElementById(\"txtWorkflowDefId\").value;\r\n" +
                "        RecordId=document.getElementById(\"txtRecordId\").value;\r\n" +
                "        ExtraInfo=document.getElementById(\"txtExtraInfo\").value;\r\n" +
                "        oReturnParam=Portal.Workflow.Bussiness.UserAjaxWorkflowTaskNextLink.ServerSideGetLinkUrl(SiteId, WorkflowDefId,WorkflowActionId, RecordId, ExtraInfo, LinkId).value;\r\n" +
                "        if(oReturnParam.IsError)\r\n"+
                "        {\r\n"+
                "           alert(oReturnParam.HtmlContent);\r\n"+
                "           return;\r\n"+
                "        }\r\n"+
                "        if(oReturnParam.IsLink)\r\n" +
                "        {\r\n" +
                "           window.open(oReturnParam.Url,'_self');\r\n"+
                "           return;\r\n"+
                "        }\r\n" +
                "        else\r\n"+
                "        {\r\n"+
                "           AttachFileSessionId=document.getElementById(\"txtAttachFileSessionId\").value;\r\n" +
                "           UserIds='';\r\n" +
                "           if(document.getElementById(\"txtSendToUsers\")!=null)\r\n" +
                "           {\r\n" +
                "                UserIds=document.getElementById(\"txtSendToUsers\").value;\r\n" +
                "           }\r\n" +
                "           CcUserIds='';\r\n" +
                "           if(document.getElementById(\"txtSendToUsersRelation\")!=null)\r\n" +
                "           {\r\n" +
                "               CcUserIds=document.getElementById(\"txtSendToUsersRelation\").value;\r\n" +
                "           }\r\n" +
                "           Note=document.getElementById(\"txtNote\").value;\r\n" +
                "           ProcessDate='';\r\n" +
                "           if(document.getElementById(\"txtProcessDate\")!=null)\r\n" +
                "           {\r\n" +
                "               ProcessDate=document.getElementById(\"txtProcessDate\").value;\r\n" +
                "           }\r\n" +
                "           AttachedDocumentIds=ClientGetAttachDocumentIds();\r\n" +
                "           HasResponsible=0;\r\n" +
                "           ResponsibleId='';\r\n" +
                "           Responsible='';\r\n" +
                "           JoinerId='';\r\n" +
                "           Joiner='';\r\n" +
                "           if(document.getElementById('txtResponsibleId')!=null)\r\n" +
                "           {\r\n" +
                "               HasResponsible=1;\r\n" +
                "               ResponsibleId=document.getElementById('txtResponsibleId').value;\r\n" +
                "               Responsible=document.getElementById('txtResponsible').value;\r\n" +
                "               JoinerId=document.getElementById('txtJoinerId').value;\r\n" +
                "               Joiner=document.getElementById('txtJoiner').value;\r\n" +
                "           }\r\n" +
                
                "           oDoNextLinkRetCls=Portal.Workflow.Bussiness.UserAjaxWorkflowTaskNextLink.ServerSideDoNextLink(SiteId, WorkflowDefId, WorkflowActionId, RecordId, LinkId, Note, UserIds, CcUserIds, ProcessDate, AttachFileSessionId, AttachedDocumentIds, ResponsibleId, Responsible, JoinerId, Joiner, HasResponsible, ExtraInfo).value;\r\n" +
                "           if(oDoNextLinkRetCls.IsError==true)\r\n" +
                "           {\r\n" +
                "               alert(oDoNextLinkRetCls.ReturnMsg);\r\n" +
                "               return;\r\n" +
                "           }\r\n" +
                "           if(oDoNextLinkRetCls.IsLink)\r\n"+
                "           {\r\n"+
                "               window.open(oDoNextLinkRetCls.Url,'_self');\r\n"+
                "               return;\r\n"+
                "           }\r\n"+
                "           alert(oDoNextLinkRetCls.ReturnMsg);\r\n" +
                "           document.getElementById('"+ContentWorkflow+"').innerHTML='<div class=CssProcessWorkflowOk>Xử lý quy trình chuyển thành công!</div>';\r\n"+
                "           if(CallBackFromWorkflowForRefresh!=null)CallBackFromWorkflowForRefresh();" +
                "       }\r\n"+
                "   };\r\n" +
                "   var AllowProcess=true;\r\n"+
                "   function ClientProcessToUser(LoginName,Id)\r\n"+
                "   {\r\n"+
                "           if(AllowProcess==false)return;\r\n"+
                "           UserIds='';\r\n" +
                "           if(document.getElementById(\"txtSendToUsers\")!=null)\r\n" +
                "           {\r\n" +
                "                UserIds=document.getElementById(\"txtSendToUsers\").value;\r\n" +
                "                checked=document.getElementById(Id).checked;\r\n"+
                "                oReturnParam=Portal.Workflow.Bussiness.UserAjaxWorkflowTaskNextLink.ServerSideProcessUser(SiteId, UserIds, LoginName, checked).value;\r\n" +
                "                if(oReturnParam.IsError==true)\r\n" +
                "                {\r\n" +
                "                   alert(oReturnParam.HtmlContent);\r\n" +
                "                   return;\r\n" +
                "                }\r\n" +
                "                document.getElementById('txtSendToUsers').value=oReturnParam.HtmlContent;\r\n" +
                "           }\r\n" +
                "   }\r\n"+

                "   function ClientProcessViewUser(LoginName,Id)\r\n" +
                "   {\r\n" +
                "           if(AllowProcess==false)return;\r\n" +
                "           UserIds='';\r\n" +
                "           if(document.getElementById(\"txtSendToUsersRelation\")!=null)\r\n" +
                "           {\r\n" +
                "                UserIds=document.getElementById(\"txtSendToUsersRelation\").value;\r\n" +
                "                checked=document.getElementById(Id).checked;\r\n" +
                "                oReturnParam=Portal.Workflow.Bussiness.UserAjaxWorkflowTaskNextLink.ServerSideProcessUser(SiteId, UserIds, LoginName, checked).value;\r\n" +
                "                if(oReturnParam.IsError==true)\r\n" +
                "                {\r\n" +
                "                   alert(oReturnParam.HtmlContent);\r\n" +
                "                   return;\r\n" +
                "                }\r\n" +
                "                document.getElementById('txtSendToUsersRelation').value=oReturnParam.HtmlContent;\r\n" +
                "           }\r\n" +
                "   }\r\n" +


                "   function ClientProcessToAllUser()\r\n" +
                "   {\r\n" +
                "       AllowProcess=false;\r\n"+
                "       checked = document.getElementById('chkAllToUser').checked;\r\n"+
                "       Ids=document.getElementById('txtToCheckedText').value;\r\n"+
                "       AllIds=Ids.split(';');\r\n"+
                "       if(checked==false)\r\n"+
                "       {\r\n"+
                "           document.getElementById('txtSendToUsers').value='';\r\n" +
                "       }\r\n"+
                "       else\r\n"+
                "       {\r\n"+
                "           document.getElementById('txtSendToUsers').value=document.getElementById('txtSendToUsersHidden').value;\r\n"+
                "       }\r\n"+
                "       for(var iIndex=0;iIndex<AllIds.length;iIndex++)\r\n"+
                "       {\r\n"+
                "           if(document.getElementById(AllIds[iIndex])!=null)\r\n"+
                "           {\r\n"+
                "               document.getElementById(AllIds[iIndex]).checked=checked;\r\n"+
                "           }\r\n"+
                "       }\r\n"+
                "       AllowProcess=true;\r\n" +
                "   }\r\n" +

                "   function ClientProcessRelAllUser()\r\n" +
                "   {\r\n" +
                "       AllowProcess=false;\r\n" +
                "       Ids=document.getElementById('txtViewCheckedText').value;\r\n" +
                "       AllIds=Ids.split(';');\r\n" +
                "       checked = document.getElementById('chkAllRelUser').checked;\r\n" +
                "       if(checked==false)\r\n" +
                "       {\r\n" +
                "           document.getElementById('txtSendToUsersRelation').value='';\r\n" +
                "       }\r\n" +
                "       else\r\n"+
                "       {\r\n"+
                "           document.getElementById('txtSendToUsersRelation').value=document.getElementById('txtSendToUsersRelationHidden').value;\r\n" +
                "       }\r\n"+
                "       for(var iIndex=0;iIndex<AllIds.length;iIndex++)\r\n" +
                "       {\r\n" +
                "           if(document.getElementById(AllIds[iIndex])!=null)\r\n" +
                "           {\r\n" +
                "               document.getElementById(AllIds[iIndex]).checked=checked;\r\n" +
                "           }\r\n" +
                "       }\r\n" +
                "       AllowProcess=true;\r\n" +
                "   }\r\n" +
                "</script>\r\n";
            return JavascriptText;
        }

        [AjaxPro.AjaxMethod]
        public string Draw(
            string SiteId,
            string WorkflowDefId,
            string WorkflowActionId,
            string SelectedLinkId,
            string RecordId)
        {
            SiteParam oSiteParam = WebEnvironments.CreateSiteParam(SiteId);
            if (String.IsNullOrEmpty(SelectedLinkId)) SelectedLinkId = "";
            string ExtraInfo = new Workflow.Bussiness.WorkflowBll().ServerSideGetExtraInfo(oSiteParam.ConnectionString, WorkflowActionId);
            if (string.IsNullOrEmpty(ExtraInfo)) ExtraInfo = "";

            string RetHtml =
                "<input id=\"txtExtraInfo\" type=\"hidden\" value=\"" + ExtraInfo + "\">\r\n" +
                "<input id=\"txtAttachFileSessionId\" type=\"hidden\" value=\"" + SessionId + "\">\r\n" +
                "<div id=\"divUserAjaxWorkflowTaskNextLink\" class=\"CssWorkflowTaskContentNextLink\">" + GetHtml(SiteId, WorkflowDefId, WorkflowActionId, RecordId, ExtraInfo, SelectedLinkId) + "</div>\r\n";
            return RetHtml;
        }


        string GetLinkUrl(
            Workflow.Library.WorkFlowApp wfa, 
            string SiteId, 
            string LinkId,
            string RecordId,
            string WorkflowDefId,
            string WorkflowActionId,
            string ExtraInfo)
        {
            SiteParam oSiteParam = WebEnvironments.CreateSiteParam(SiteId);
              
            LinkCls oLinkCls = wfa.GetLink(LinkId);
            if (String.IsNullOrEmpty(oLinkCls.RunFunctionId) == false)
            {
                string[] FunctionIds = oLinkCls.RunFunctionId.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                for (int iIndex = 0; iIndex < FunctionIds.Length; iIndex++)
                {
                    string DllPath = oSiteParam.DllPath;
                    IWfFunction
                        WfFunction = WorkFlowFunctionMan.Find(DllPath, FunctionIds[iIndex]);
                    if (WfFunction != null)
                    {
                        WfExecuteParamCls oWfExecuteParamCls = new WfExecuteParamCls();
                        oWfExecuteParamCls.RecordId = RecordId;
                        oWfExecuteParamCls.WorkflowDefId = WorkflowDefId;
                        oWfExecuteParamCls.WorkflowActionId = WorkflowActionId;
                        oWfExecuteParamCls.SiteId = SiteId;
                        oWfExecuteParamCls.ExtraParam = ExtraInfo;

                        string LinkUrl = WfFunction.GetLinkUrl(oWfExecuteParamCls);
                        if (string.IsNullOrEmpty(LinkUrl) == false)
                        {
                            return LinkUrl;
                        }
                    }
                }
            }
            return "";
        }

        [AjaxPro.AjaxMethod]
        public ReturnParamCls ServerSideGetLinkUrl(
            string SiteId,
            string WorkflowDefId,
            string WorkflowActionId,
            string RecordId,
            string ExtraInfo,
            string LinkId)
        {
            ReturnParamCls oReturnParamCls = new ReturnParamCls();
            try
            {
                string Html = "";
                SiteParam oSiteParam = WebEnvironments.CreateSiteParam(SiteId);
                Workflow.Library.WorkFlowApp wfa = WorkflowBll.CreateWorkflowAppFromWorkflowAction(oSiteParam.ConnectionString, WorkflowActionId);
                
                string LinkUrl = GetLinkUrl(wfa, SiteId, LinkId, RecordId, WorkflowDefId, WorkflowActionId, ExtraInfo);
                if (!string.IsNullOrEmpty(LinkUrl))
                {
                    oReturnParamCls.IsLink = true;
                    oReturnParamCls.Url = LinkUrl;
                    oReturnParamCls.HtmlContent = "Thực hiện mở liên kết! Xin vui lòng chọn nút [thực hiện xử lý] để thực hiện đường chuyển";
                    return oReturnParamCls;
                }
                else
                {
                    Html = Draw(SiteId, WorkflowDefId, WorkflowActionId, LinkId, RecordId);
                    oReturnParamCls.HtmlContent = Html;
                    return oReturnParamCls;
                }
            }
            catch (Exception ex)
            {
                oReturnParamCls.IsError = true;
                oReturnParamCls.HtmlContent = ex.Message.ToString();
                return oReturnParamCls;
            }
        }



        [AjaxPro.AjaxMethod]
        public DoNextLinkRetCls ServerSideDoNextLink(
            string SiteId,
            string WorkflowDefId,
            string WorkflowActionId,
            string RecordId,
            string LinkId,
            string Note,
            string FullNameSendToUserIds,
            string FullNameCCToUserIds,
            string ProcessDate,
            string AttachFileSessionId,
            string AttachedDocumentIds,
            string ResponsibleId,
            string Responsible,
            string JoinerId,
            string Joiner,
            int HasResponsible,
            string ExtraInfo)
        {
            DoNextLinkRetCls oDoNextLinkRetCls = new DoNextLinkRetCls();
            SiteParam oSiteParam = WebEnvironments.CreateSiteParam(SiteId);
            Workflow.Library.WorkFlowApp wfa = WorkflowBll.CreateWorkflowAppFromWorkflowAction(oSiteParam.ConnectionString, WorkflowActionId);
            
            if (string.IsNullOrEmpty(AttachedDocumentIds)) AttachedDocumentIds = "";
            
            try
            {
                string LinkUrl = GetLinkUrl(wfa, SiteId, LinkId, RecordId, WorkflowDefId, WorkflowActionId, ExtraInfo);
                if (!string.IsNullOrEmpty(LinkUrl))
                {
                    oDoNextLinkRetCls.IsLink = true;
                    oDoNextLinkRetCls.Url = LinkUrl;
                    return oDoNextLinkRetCls;
                }

                //chuyen thanh login
                if (HasResponsible == 1)
                {
                    if (string.IsNullOrEmpty(ResponsibleId)) throw new Exception("Vui lòng chọn chủ trì!");
                }
                int iProcessDate = 2;

                if (!string.IsNullOrEmpty(ProcessDate))
                {
                    try
                    {
                        DateTime dDateProcess = FunctionUtilities.VNDateToDate(ProcessDate);
                        iProcessDate = dDateProcess.Subtract(System.DateTime.Now).Days;
                    }
                    catch
                    {
                        throw new Exception("Hạn xử lý nhập không hợp lệ!");
                    }
                }
                string WorkflowFunction = "";

                string SendToUserIds = FullNameSendToUserIds;// wfa.ConvertFullIds(FullNameSendToUserIds);
                string CCToUserIds = FullNameCCToUserIds;// wfa.ConvertFullIds(FullNameCCToUserIds);

                LinkCls oLinkCls = new WorkflowBll().GetLink(wfa, LinkId);
                if (oLinkCls.NextForStatus==0 && oLinkCls.ForAllEmployeeInRole == 1 && oLinkCls.FinishThisTask == 0)
                {
                    if (string.IsNullOrEmpty(SendToUserIds))
                    {
                        throw new Exception("Đường xử lý công việc này cần xác định đối tượng xử lý!");
                    }
                }
                EmployeeCls[] DedicateUsers = null;
                if (oLinkCls.SendRoleType == 1)
                {
                    ArrayList ArrayListRoles = new ArrayList();
                    Hashtable hsRoles = new Hashtable();

                    ArrayList ArrayListViewRoles = new ArrayList();
                    Hashtable hsViewRoles = new Hashtable();

                    ArrayList ArrayListUsers = new ArrayList();
                    ArrayList ArrayListCcUsers = new ArrayList();

                    string CurrentOffice = WebSessionUtility.GetCurrentLoginUser().AssetCode;

                    string BatchId = System.Guid.NewGuid().ToString();
                    string[] Users = SendToUserIds.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    string[] CcUsers = CCToUserIds.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                    //kiem tra xem co nam trong danh sach tai khoan duoc chuyen khong
                    string DllPath = oSiteParam.DllPath;
                    string ToUsers = new WorkflowBll().ServerSideGetToUsersByLoginName(DllPath, oSiteParam.ConnectionString, WorkflowDefId, WorkflowActionId, LinkId);
                    string ViewUsers = new WorkflowBll().ServerSideGetViewUsersByLoginName(DllPath, oSiteParam.ConnectionString, WorkflowDefId, LinkId);
                    string[] AllowToUsers = ToUsers.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    string[] AllowViewUsers = ViewUsers.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                    for (int iCheck = 0; iCheck < Users.Length; iCheck++)
                    {
                        bool Allow = false;
                        for (int iUser = 0; iUser < AllowToUsers.Length; iUser++)
                        {
                            if (AllowToUsers[iUser].ToLower().Trim().Equals(Users[iCheck].Trim().ToLower()))
                            {
                                Allow = true;
                                break;
                            }
                        }
                        if (!Allow)
                        {
                            throw new Exception("Tài khoản: " + Users[iCheck] + " không nằm trong phạm vi được chuyển!");
                        }
                    }


                    for (int iCheck = 0; iCheck < CcUsers.Length; iCheck++)
                    {
                        bool Allow = false;
                        for (int iUser = 0; iUser < AllowViewUsers.Length; iUser++)
                        {
                            if (AllowViewUsers[iUser].ToLower().Trim().Equals(CcUsers[iCheck].Trim().ToLower()))
                            {
                                Allow = true;
                                break;
                            }
                        }
                        if (!Allow)
                        {
                            throw new Exception("Tài khoản: " + CcUsers[iCheck] + " không nằm trong phạm vi được xem!");
                        }
                    }

                    string[] ToRoleIds = oLinkCls.RoleIds;
                    string[] ViewRoleIds = oLinkCls.ViewRoleIds;
                    ArrayList ArrayListUserInRoles = null;
                    for (int iIndexUser = 0; iIndexUser < Users.Length; iIndexUser++)
                    {
                        string ItemLoginName = (string)Users[iIndexUser];
                        EmployeeCls EmployeeCls = WorkflowBll.CreateEmployeeModelFromUser(SiteId,ItemLoginName);
                        if (EmployeeCls == null) throw new Exception("Tài khoản: " + ItemLoginName + " không tìm thấy trong quy trình!");
                        //kiem tra xem co nam trong role duoc chuyen khong??
                        bool Found = false;
                        for (int iCheckRole = 0; iCheckRole < ToRoleIds.Length; iCheckRole++)
                        {
                            for (int iTempCheck = 0; iTempCheck < EmployeeCls.TempRoleId.Length; iTempCheck++)
                            {
                                if (ToRoleIds[iCheckRole].Equals(EmployeeCls.TempRoleId[iTempCheck]))
                                {
                                    Found = true;
                                    break;
                                }
                            }
                        }
                        if (!Found)
                        {
                            throw new Exception("Tài khoản: " + EmployeeCls.LoginName + " không nằm trong phạm vi được chuyển!");
                        }

                        for (int iIndexRole = 0; iIndexRole < EmployeeCls.TempRoleId.Length; iIndexRole++)
                        {
                            if (hsRoles.Contains(EmployeeCls.TempRoleId[iIndexRole]) == false)
                            {
                                if (oLinkCls.LinkType.Equals("Sperator"))
                                {
                                    BatchId = System.Guid.NewGuid().ToString().Substring(0, 8);
                                }
                                ArrayListUserInRoles = new ArrayList();
                                EmployeeCls.OfficeCode = CurrentOffice;
                                EmployeeCls.BatchId = BatchId;
                                EmployeeCls.ProcessType = "to";
                                ArrayListUserInRoles.Add(EmployeeCls);
                                hsRoles.Add(EmployeeCls.TempRoleId[iIndexRole], ArrayListUserInRoles);
                                ArrayListRoles.Add(EmployeeCls.TempRoleId[iIndexRole]);
                            }
                            else
                            {
                                ArrayListUserInRoles = (ArrayList)hsRoles[EmployeeCls.TempRoleId[iIndexRole]];
                                ArrayListUserInRoles.Add(EmployeeCls);
                            }
                        }
                    }


                    //doan nay xu ly cho can bo chi xem
                    ArrayListUserInRoles = null;
                    for (int iIndexUser = 0; iIndexUser < CcUsers.Length; iIndexUser++)
                    {
                        string ItemLoginName = (string)CcUsers[iIndexUser];
                        EmployeeCls EmployeeCls = WorkflowBll.CreateEmployeeModelFromUser(SiteId, ItemLoginName);
                        for (int iIndexRole = 0; iIndexRole < EmployeeCls.TempRoleId.Length; iIndexRole++)
                        {
                            if (hsViewRoles.Contains(EmployeeCls.TempRoleId[iIndexRole]) == false)
                            {
                                if (oLinkCls.LinkType.Equals("Sperator"))
                                {
                                    BatchId = System.Guid.NewGuid().ToString().Substring(0, 8);
                                }
                                ArrayListUserInRoles = new ArrayList();
                                EmployeeCls.OfficeCode = CurrentOffice;
                                EmployeeCls.BatchId = BatchId;
                                EmployeeCls.ProcessType = "view";
                                ArrayListUserInRoles.Add(EmployeeCls);
                                hsViewRoles.Add(EmployeeCls.TempRoleId[iIndexRole], ArrayListUserInRoles);
                                ArrayListViewRoles.Add(EmployeeCls.TempRoleId[iIndexRole]);
                            }
                            else
                            {
                                ArrayListUserInRoles = (ArrayList)hsViewRoles[EmployeeCls.TempRoleId];
                                if (ArrayListUserInRoles != null)
                                {
                                    ArrayListUserInRoles.Add(EmployeeCls);
                                }
                            }
                        }
                    }

                    

                    for (int iIndex = 0; iIndex < ArrayListRoles.Count; iIndex++)
                    {
                        string RoleId = (string)ArrayListRoles[iIndex];
                        ArrayList ArrayListEmployeesInRole = (ArrayList)hsRoles[RoleId];
                        for (int iSub = 0; iSub < ArrayListEmployeesInRole.Count; iSub++)
                        {
                            EmployeeCls EmployeeCls = (EmployeeCls)ArrayListEmployeesInRole[iSub];// wfa.FindEmployee(ItemEmployeeId);
                            ArrayListUsers.Add(EmployeeCls);
                        }
                    }


                    for (int iIndex = 0; iIndex < ArrayListViewRoles.Count; iIndex++)
                    {
                        string RoleId = (string)ArrayListViewRoles[iIndex];
                        ArrayList ArrayListEmployeesInRole = (ArrayList)hsViewRoles[RoleId];
                        for (int iSub = 0; iSub < ArrayListEmployeesInRole.Count; iSub++)
                        {
                            EmployeeCls EmployeeCls = (EmployeeCls)ArrayListEmployeesInRole[iSub];// wfa.FindEmployee(ItemEmployeeId);
                            //kiem tra xem co thang nay chua...!
                            bool HasEmployee = false;
                            for (int iCheck = 0; iCheck < ArrayListUsers.Count; iCheck++)
                            {
                                EmployeeCls ItemCheck = (EmployeeCls)ArrayListUsers[iCheck];
                                if (ItemCheck.EmployeeId.Equals(EmployeeCls.EmployeeId))
                                {
                                    HasEmployee = true;
                                    break;
                                }
                            }
                            if (!HasEmployee)
                            {
                                ArrayListUsers.Add(EmployeeCls);
                            }
                        }
                    }




                    DedicateUsers = new EmployeeCls[ArrayListUsers.Count];
                    //if (DedicateUsers.Length == 0)
                    //{
                    //    if(oLinkCls.FinishThisTask!=0){
                    //    throw new Exception("Chưa xác định đối tượng chuyển!");
                    //}

                    for (int iIndex = 0; iIndex < DedicateUsers.Length; iIndex++)
                    {
                        DedicateUsers[iIndex] = (EmployeeCls)ArrayListUsers[iIndex];
                    }
                    string SenderRoleOffice = CurrentOffice;

                    if (DedicateUsers == null) DedicateUsers = new EmployeeCls[0];
                    //doan nay loai bo nhung thang nao khong nam trong role chuyen
                    ArrayList ArrayListSent = new ArrayList();
                    for (int iIndex = 0; iIndex < DedicateUsers.Length; iIndex++)
                    {
                        for (int iIndexRole = 0; iIndexRole < DedicateUsers[iIndex].TempRoleId.Length; iIndexRole++)
                        {
                            bool HasExists = false;
                            string ItemTempRoleId = DedicateUsers[iIndex].TempRoleId[iIndexRole];
                            string ProcessType = DedicateUsers[iIndex].ProcessType;
                            for (int iCheckHasExits = 0; iCheckHasExits < ArrayListSent.Count; iCheckHasExits++)
                            {
                                EmployeeCls CheckEmployeeCls = (EmployeeCls)ArrayListSent[iCheckHasExits];
                                if (CheckEmployeeCls.TempRoleId[0].Equals(ItemTempRoleId) && CheckEmployeeCls.EmployeeId.Equals(DedicateUsers[iIndex].EmployeeId) && ProcessType.ToLower().Equals(CheckEmployeeCls.ProcessType.ToLower()))
                                {
                                    HasExists = true;
                                    break;
                                }
                            }
                            if (!HasExists)
                            {
                                EmployeeCls oEmployeeCls = new EmployeeCls();
                                oEmployeeCls.BatchId = DedicateUsers[iIndex].BatchId;
                                oEmployeeCls.EmployeeId = DedicateUsers[iIndex].EmployeeId;
                                oEmployeeCls.FullName = DedicateUsers[iIndex].FullName;
                                oEmployeeCls.LoginName = DedicateUsers[iIndex].LoginName;
                                oEmployeeCls.OfficeCode = DedicateUsers[iIndex].OfficeCode;
                                oEmployeeCls.ProcessType = DedicateUsers[iIndex].ProcessType;
                                oEmployeeCls.TempRoleId = new string[] { ItemTempRoleId };

                                ArrayListSent.Add(oEmployeeCls);
                            }
                        }
                    }

                    ArrayList ArrayListSendToAllow = new ArrayList();
                    for (int iIndex = 0; iIndex < ArrayListSent.Count; iIndex++)
                    {
                        EmployeeCls oEmployeeCls = (EmployeeCls)ArrayListSent[iIndex];
                        if (oEmployeeCls.ProcessType.ToLower().Equals("to"))
                        {
                            for (int iCheck = 0; iCheck < ToRoleIds.Length; iCheck++)
                            {
                                if (oEmployeeCls.TempRoleId[0].Equals(ToRoleIds[iCheck]))
                                {
                                    ArrayListSendToAllow.Add(oEmployeeCls);
                                    break;
                                }
                            }
                        }
                    }
                    for (int iIndex = 0; iIndex < ArrayListSent.Count; iIndex++)
                    {
                        EmployeeCls oEmployeeCls = (EmployeeCls)ArrayListSent[iIndex];
                        if (oEmployeeCls.ProcessType.ToLower().Equals("view"))
                        {
                            for (int iCheck = 0; iCheck < ViewRoleIds.Length; iCheck++)
                            {
                                if (oEmployeeCls.TempRoleId[0].Equals(ViewRoleIds[iCheck]))
                                {
                                    ArrayListSendToAllow.Add(oEmployeeCls);
                                    break;
                                }
                            }
                        }
                    }

                    DedicateUsers = new EmployeeCls[ArrayListSendToAllow.Count];
                    for (int iIndex = 0; iIndex < ArrayListSendToAllow.Count; iIndex++)
                    {
                        DedicateUsers[iIndex] = (EmployeeCls)ArrayListSendToAllow[iIndex];
                    }
                }
                else
                {
                    //khong can check roles...!
                    string CurrentOffice = WebSessionUtility.GetCurrentLoginUser().AssetCode;
                    ArrayList ArrayListSendTo = new ArrayList();
                    string BatchId = System.Guid.NewGuid().ToString();
                    string[] Users = SendToUserIds.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    string[] CcUsers = CCToUserIds.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int iIndex = 0; iIndex < Users.Length; iIndex++)
                    {
                        EmployeeCls FoundEmployeeCls = WorkflowBll.CreateEmployeeModelFromUser(SiteId,Users[iIndex]);
                        if (FoundEmployeeCls != null)
                        {
                            for (int iIndexRole = 0; iIndexRole < FoundEmployeeCls.TempRoleId.Length; iIndexRole++)
                            {
                                EmployeeCls SendEmployeeCls = new EmployeeCls();
                                SendEmployeeCls.BatchId = FoundEmployeeCls.BatchId;
                                SendEmployeeCls.EmployeeId = FoundEmployeeCls.EmployeeId;
                                SendEmployeeCls.FullName = FoundEmployeeCls.FullName;
                                SendEmployeeCls.LoginName = FoundEmployeeCls.LoginName;
                                SendEmployeeCls.OfficeCode = CurrentOffice;
                                SendEmployeeCls.ProcessType = "to";
                                SendEmployeeCls.TempRoleId = new string[] { FoundEmployeeCls.TempRoleId[iIndexRole] };

                                ArrayListSendTo.Add(SendEmployeeCls);
                            }
                        }
                    }


                    for (int iIndex = 0; iIndex < CcUsers.Length; iIndex++)
                    {
                        EmployeeCls FoundEmployeeCls = WorkflowBll.CreateEmployeeModelFromUser(SiteId, CcUsers[iIndex]);
                        if (FoundEmployeeCls != null)
                        {
                            for (int iIndexRole = 0; iIndexRole < FoundEmployeeCls.TempRoleId.Length; iIndexRole++)
                            {
                                EmployeeCls SendEmployeeCls = new EmployeeCls();
                                SendEmployeeCls.BatchId = FoundEmployeeCls.BatchId;
                                SendEmployeeCls.EmployeeId = FoundEmployeeCls.EmployeeId;
                                SendEmployeeCls.FullName = FoundEmployeeCls.FullName;
                                SendEmployeeCls.LoginName = FoundEmployeeCls.LoginName;
                                SendEmployeeCls.OfficeCode = CurrentOffice;
                                SendEmployeeCls.ProcessType = "view";
                                SendEmployeeCls.TempRoleId = new string[] { FoundEmployeeCls.TempRoleId[iIndexRole] };

                                ArrayListSendTo.Add(SendEmployeeCls);
                            }
                        }
                    }


                    DedicateUsers = new EmployeeCls[ArrayListSendTo.Count];
                    for (int iIndex = 0; iIndex < ArrayListSendTo.Count; iIndex++)
                    {
                        DedicateUsers[iIndex] = (EmployeeCls)ArrayListSendTo[iIndex];
                    }
                }

                DataSet dsUsers = new DataSet();
                dsUsers.Tables.Add("Info");
                dsUsers.Tables["Info"].Columns.Add("EmployeeId");
                dsUsers.Tables["Info"].Columns.Add("LoginName");
                dsUsers.Tables["Info"].Columns.Add("FullName");
                dsUsers.Tables["Info"].Columns.Add("RoleId");
                dsUsers.Tables["Info"].Columns.Add("OfficeCode");
                dsUsers.Tables["Info"].Columns.Add("BatchId");
                dsUsers.Tables["Info"].Columns.Add("ProcessType");

                for (int iIndex = 0; iIndex < DedicateUsers.Length; iIndex++)
                {
                    for (int iIndexRole = 0; iIndexRole < DedicateUsers[iIndex].TempRoleId.Length; iIndexRole++)
                    {
                        dsUsers.Tables["Info"].Rows.Add(new object[]{
                            DedicateUsers[iIndex].EmployeeId,
                            DedicateUsers[iIndex].LoginName,
                            DedicateUsers[iIndex].FullName,
                            DedicateUsers[iIndex].TempRoleId[iIndexRole],
                            DedicateUsers[iIndex].OfficeCode,
                            DedicateUsers[iIndex].BatchId,
                            DedicateUsers[iIndex].ProcessType
                        });
                    }
                }


                Collection<CallWsFunction> CallWsFunctions = new Collection<CallWsFunction> { };
                if (String.IsNullOrEmpty(oLinkCls.RunFunctionId) == false)
                {
                    string[] FunctionIds = oLinkCls.RunFunctionId.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    DataSet ds = new DataSet("XmlFunctionWorkflow");
                    ds.Tables.Add("Wf");
                    ds.Tables["Wf"].Columns.Add("WorkflowDefId");
                    ds.Tables["Wf"].Columns.Add("WorkflowActionId");
                    ds.Tables["Wf"].Columns.Add("RecordId");
                    ds.Tables["Wf"].Columns.Add("WorkflowFunctionId");
                    ds.Tables["Wf"].Columns.Add("RunCommandText");
                    ds.Tables["Wf"].Columns.Add("XmlData");
                    ds.Tables["Wf"].Columns.Add("RunAtServer");
                    ds.Tables["Wf"].Columns.Add("SiteId");

                    for (int iIndex = 0; iIndex < FunctionIds.Length; iIndex++)
                    {
                        string DllPath = oSiteParam.DllPath;
                        FunctionIds[iIndex] = FunctionIds[iIndex].Trim();
                        IWfFunction
                            WfFunction = WorkFlowFunctionMan.Find(DllPath, FunctionIds[iIndex]);
                        if (WfFunction != null)
                        {
                            if (WfFunction.RunAtServer == false)
                            {
                                WfExecuteParamCls oWfExecuteParamCls = new WfExecuteParamCls();
                                oWfExecuteParamCls.RecordId = RecordId;
                                oWfExecuteParamCls.WorkflowDefId = WorkflowDefId;
                                oWfExecuteParamCls.WorkflowActionId = WorkflowActionId;
                                oWfExecuteParamCls.SiteId = SiteId;
                                RetWfExecuteParamCls oRetWfExecuteParamCls = WfFunction.Execute(oWfExecuteParamCls);
                                if (oRetWfExecuteParamCls.Error)
                                {
                                    throw new Exception(oRetWfExecuteParamCls.ReturnMsg);
                                }
                                if (oRetWfExecuteParamCls.ReturnIsLink)
                                {
                                    oDoNextLinkRetCls.Url = oRetWfExecuteParamCls.Url;
                                    //return oDoNextLinkRetCls;
                                }
                                if (oRetWfExecuteParamCls.Done)
                                {
                                    CallWsFunction oCallWsFunction = new CallWsFunction();
                                    oCallWsFunction.Command = WfFunction.WsCommandText;
                                    oCallWsFunction.XmlData = oRetWfExecuteParamCls.XmlData;
                                    oCallWsFunction.RecordId = RecordId;
                                    oCallWsFunction.RunAtServer = WfFunction.RunAtServer;

                                    CallWsFunctions.Add(oCallWsFunction);
                                }
                            }
                            else
                            {
                                ds.Tables["Wf"].Rows.Add(new object[]{
                                    WorkflowDefId,WorkflowActionId,RecordId,FunctionIds[iIndex].Trim(),"","",true,SiteId
                                });
                            }
                        }
                    }
                    WorkflowFunction = ds.GetXml();
                    //doan nay call WebService de xu ly du lieu...!
                }

                string XmlUsers = dsUsers.GetXml();
                string XmlData = "";
                string FlashQueuePath = WebConfig.GetConfigFromXml(oSiteParam, "FlashQueuePath");
                Portal.Workflow.Bussiness.WorkflowBll.DoNextLinkRunAtServerReturnCls
                    oDoNextLinkRunAtServerReturnCls = new WorkflowBll().DoNextLinkRunAtServer(SiteId, null, LinkId, WorkflowActionId, Note, XmlUsers, XmlData, iProcessDate.ToString(), WorkflowFunction, AttachFileSessionId, AttachedDocumentIds, FlashQueuePath, ResponsibleId, Responsible, JoinerId, Joiner);
                //try
                //{
                //    SystemLogBll.AddBackendSystemLog(SiteId, Environments.CurrentLoginUser.LoginName, oLinkCls.LinkName, WorkflowDefId, wfa.WorkFlowDefCls.WorkFlowName, "NextActivity", "Workflow", "Chuyển trạng thái");
                //}
                //catch { }
                oDoNextLinkRetCls.IsLink = oDoNextLinkRunAtServerReturnCls.IsLink;
                oDoNextLinkRetCls.Url = oDoNextLinkRunAtServerReturnCls.Url;
                oDoNextLinkRetCls.ReturnMsg = "Đã chuyển công việc thành công!";
                return oDoNextLinkRetCls;
            }
            catch (Exception ex)
            {
                oDoNextLinkRetCls.IsError = true;
                oDoNextLinkRetCls.ReturnMsg = ex.Message.ToString();
                return oDoNextLinkRetCls;
            }
        }

     
        //[AjaxPro.AjaxMethod]
        //public DoNextLinkRetCls ServerSideDetectUsers(
        //    string SiteId,
        //    string WorkflowDefId, 
        //    string WorkflowActionId,
        //    string RecordId, 
        //    string LinkId)
        //{
        //    DoNextLinkRetCls oDoNextLinkRetCls = new DoNextLinkRetCls();
        //    try
        //    {
        //        WebSessionUtility.CheckSessionTimeOut();
        //        SiteParam oSiteParam = WebEnvironments.CreateSiteParam(SiteId);
        //        DataTable dtRole = new WorkflowBll().GetWfRoleInLink(oSiteParam.PathRoot, oSiteParam.ConnectionString, WorkflowActionId, LinkId);
        //        string LoginName = WebSessionUtility.GetCurrentLoginUser().LoginName;

        //        string DllPath = oSiteParam.DllPath;// oSiteParam.PathRoot + "\\bin";
        //        string ToUsers = new WorkflowBll().ServerSideGetToUsersByFullName(DllPath, oSiteParam.ConnectionString, WorkflowDefId, WorkflowActionId, LinkId);
        //        string ViewUsers = new WorkflowBll().ServerSideGetViewUsersByFullName(DllPath, oSiteParam.ConnectionString, WorkflowDefId, LinkId);
        //        WorkflowActionInfoCls oWorkflowActionInfoCls = new WorkflowBll().ServerSideCheckStartWorkFlowRecord(oSiteParam.ConnectionString, WorkflowActionId);
        //        if (oWorkflowActionInfoCls.StartWorkflowRecord)
        //        {
        //            if (!String.IsNullOrEmpty(oWorkflowActionInfoCls.SendToUsers))
        //            {
        //                ToUsers = oWorkflowActionInfoCls.SendToUsers;
        //            }
        //        }
        //        Workflow.Library.WorkFlowApp wfa=WorkflowBll.CreateWorkflowAppFromWorkflowAction(oSiteParam.ConnectionString,WorkflowActionId);
        //        LinkCls oLinkCls=wfa.GetLink(LinkId);

        //        string NextLinkInfoText = oLinkCls.NextLinkInfoText;

        //        string Html =
        //           "<div class=\"CssFormSaveUpdate\">\r\n"+
        //           "<table>\r\n" +
        //           "    <tr>\r\n" +
        //           "        <td class=Col1 valign=\"text-top\" style=\"width:140px;\">Nội dung</td>\r\n" +
        //           "        <td class=Col2 valign=\"text-top\"><textarea class=textarea type=textarea style=\"height:50px;\" id=\"txtNote\">"+NextLinkInfoText+"</textarea></td>\r\n" +
        //           //"        <td></td>\r\n" +
        //           "    </tr>\r\n";
        //        if (oLinkCls.ForAllEmployeeInRole == 1 && oLinkCls.FinishThisTask == 0 && oLinkCls.NextForStatus==0)
        //        {
        //            Html +=
        //           "    <tr style=\"display:none\">\r\n" +
        //           "        <td class=Col1 valign=\"text-top\" style=\"width:140px;\">Xử lý</td>\r\n" +
        //           "        <td class=Col2 valign=\"text-top\">\r\n" +
        //           //JQuery.AutoComplete.GetMultiLookUpUser(SiteId,"txtSendToUsers",ToUsers,false)+"\r\n"+
        //           "               <textarea class=textarea type=textarea id=\"txtSendToUsers\">" + ToUsers + "</textarea>\r\n" +
        //           "               <input type=hidden id=\"txtSendToUsersHidden\" value=\"" + ToUsers + "\">\r\n" +
        //           "        </td>\r\n" +
        //          // "        <td style=\"width:40px;\" valign=top><input id=\"cmdSelectWfSendUser\" class=\"button\" type=button value=\"Chọn\" onclick=\"javascript:ClientGetSendUser('txtSendToUsers');\"></td>\r\n" +
        //           "    </tr>\r\n" +
        //           "    <tr style=\"display:none\">\r\n" +
        //           "        <td class=Col1 valign=\"text-top\" style=\"width:140px;valign:top;\">Tham gia</td>\r\n" +
        //           "        <td class=Col2 valign=\"text-top\">\r\n" +
        //           //JQuery.AutoComplete.GetMultiLookUpUser(SiteId, "txtSendToUsersRelation", ViewUsers, true) + "\r\n" +
        //           "               <textarea class=textarea type=textarea id=\"txtSendToUsersRelation\">" + ViewUsers + "</textarea>\r\n" +
        //           "               <input type=hidden id=\"txtSendToUsersRelationHidden\" value=\"" + ViewUsers + "\">\r\n" +
        //           "        </td>\r\n" +
        //           //"        <td valign=top><input id=\"cmdSelectWfViewUser\" class=\"button\" type=button value=\"Chọn\" onclick=\"javascript:ClientGetViewUser('txtSendToUsersRelation');\"></td>\r\n" +
        //           "    </tr>\r\n";
        //        }
        //        if (oLinkCls.FinishThisTask == 0)
        //        {
        //            Html +=
        //               "    <tr style=\"display:none;\">\r\n" +
        //               "        <td class=Col1 valign=\"top\" style=\"width:140px;\">Hạn xử lý</td>\r\n" +
        //               "        <td class=Col2 valign=\"top\">\r\n" +
        //               "               "+LookUpUtilities.GenerateLookUpDate("txtProcessDate")+"\r\n" +
        //               "        </td>\r\n" +
        //               "        <td></td>\r\n" +
        //               "    </tr>\r\n";
        //        }

        //        if (oLinkCls.ShowOwner)
        //        {
        //            Html+=
        //          "    <tr>\r\n" +
        //          "        <td class=Col1 valign=top style=\"width:140px;valign:top;\">Chọn chủ trì</td>\r\n" +
        //          "        <td class=Col2 valign=top>\r\n" +
        //          "               <input id=txtResponsibleId type=hidden>\r\n"+
        //          "               <textarea class=\"CssTextArea\" id=\"txtResponsible\"></textarea>\r\n" +
        //          "        </td>\r\n" +
        //          "        <td valign=top>\r\n"+
        //          "               <input class=\"CssSelectUser\" type=button value=\"Chọn\" onclick=\"javascript:ClientDetectResponsible('txtResponsibleId','txtResponsible');\">\r\n"+
        //          "       </td>\r\n" +
        //          "    </tr>\r\n" +
        //          "    <tr>\r\n" +
        //          "        <td class=Col1 valign=top style=\"width:140px;valign:top;\">Chọn phối hợp</td>\r\n" +
        //          "        <td class=Col2 valign=top>\r\n" +
        //          "               <input id=txtJoinerId type=hidden>\r\n" +
        //          "               <textarea class=\"CssTextArea\" id=\"txtJoiner\"></textarea>\r\n" +
        //          "        </td>\r\n" +
        //          "        <td valign=top><input class=\"CssSelectUser\" type=button value=\"Chọn\" onclick=\"javascript:ClientDetectResponsible('txtJoinerId','txtJoiner');\"></td>\r\n" +
        //          "    </tr>\r\n";
        //        }

        //        Html +=
        //           "    <tr style=\"display:none;\">\r\n" +
        //           "        <td class=Col1 style=\"width:140px;\">Tài liệu gắn kèm</td>\r\n" +
        //           "        <td class=Col2>\r\n" +
        //           "            <div  id=\"divFileAttachInfo\">" + DrawAttachInfo(SiteId, SessionId) + "</div><input type=\"button\" class=cssAttachFile onclick=\"javascript:ClientUploadFile('divFileAttachInfo','" + SessionId + "');\" value=\"Chọn file gửi kèm\">\r\n" +
        //           "        </td>\r\n" +
        //           "        <td></td>\r\n" +
        //           "    </tr>\r\n" +
        //           "</table>\r\n" +
        //           "</div>\r\n";
                
        //        oDoNextLinkRetCls.ReturnMsg = Html;
        //        return oDoNextLinkRetCls;
        //    }
        //    catch (Exception ex)
        //    {
        //        oDoNextLinkRetCls.IsError = true;
        //        oDoNextLinkRetCls.ReturnMsg = ex.Message.ToString();
        //        return oDoNextLinkRetCls;
        //    }
        //}


        
        [AjaxPro.AjaxMethod]
        public string DrawAttachInfo(string SiteId, string SessionId)
        {
            string Html = "";
            SiteParam oSiteParam = WebEnvironments.CreateSiteParam(SiteId);

            string PathSave = oSiteParam.PathRoot + "\\media\\" + oSiteParam.SiteId + "\\TempUploadFiles\\" + SessionId;
            System.IO.Directory.CreateDirectory(PathSave);
            if (new System.IO.DirectoryInfo(PathSave).Exists)
            {
                Html = "<table>";
                string[] Files = System.IO.Directory.GetFiles(PathSave);

                for (int iIndex = 0; iIndex < Files.Length; iIndex++)
                {
                    System.IO.FileInfo fi = new System.IO.FileInfo(Files[iIndex]);
                    Html += " <tr>" +
                              "     <td>" + fi.Name + "</td>" +
                              "     <td><a href=\"javascript:ClientRemoveFile('" + SessionId + "','" + fi.Name + "');\">hủy bỏ</a></td>" +
                              " </tr>";
                }
                Html += "</table>";
            }
            else
            {
                Html = "";
            }
            return Html;
        }


        //[AjaxPro.AjaxMethod]
        //public string ServerSideGetSendUserUrl(
        //    string SiteId,
        //    string WorkflowDefId,
        //    string WorkflowActionId,
        //    string RecordId,
        //    string SelectedLinkId,
        //    string ParentId
        //    )
        //{
        //    try
        //    {
        //        string Url = Screen.BuildDialogUrl(SiteId, "WorkflowTaskNextLinkSelectUser", new ParamCls[]{
        //            new ParamCls("WorkflowDefId",WorkflowDefId),
        //            new ParamCls("WorkflowActionId",WorkflowActionId),
        //            new ParamCls("RecordId",RecordId),
        //            new ParamCls("LinkId",SelectedLinkId),
        //            new ParamCls("ParentId",ParentId)
        //        });
        //        if (string.IsNullOrEmpty(SelectedLinkId))
        //        {
        //            throw new Exception("Chưa xác định đường chuyển!");
        //        }
        //        return Url;
        //    }
        //    catch (Exception ex)
        //    {
        //        return "ERROR: " + ex.Message.ToString();
        //    }
        //}


        //[AjaxPro.AjaxMethod]
        //public string ServerSideGetViewUserUrl(
        //    string SiteId,
        //    string WorkflowDefId,
        //    string WorkflowActionId,
        //    string RecordId,
        //    string SelectedLinkId,
        //    string ParentId
        //    )
        //{
        //    try
        //    {
        //        string Url = Screen.BuildDialogUrl(SiteId, "WorkflowTaskNextLinkSelectViewUser", new ParamCls[]{
        //            new ParamCls("WorkflowDefId",WorkflowDefId),
        //            new ParamCls("WorkflowActionId",WorkflowActionId),
        //            new ParamCls("RecordId",RecordId),
        //            new ParamCls("LinkId",SelectedLinkId),
        //            new ParamCls("ParentId",ParentId),
        //        });
        //        if (string.IsNullOrEmpty(SelectedLinkId))
        //        {
        //            throw new Exception("Chưa xác định đường chuyển!");
        //        }
        //        return Url;
        //    }
        //    catch (Exception ex)
        //    {
        //        return "ERROR: " + ex.Message.ToString();
        //    }
        //}

        [AjaxPro.AjaxMethod]
        public string ServerSideGetOriginUrl(string SiteId, string WorkflowActionId)
        {
            try
            {
                SiteParam oSiteParam = WebEnvironments.CreateSiteParam(SiteId);
                WorkFlowRecordCls oWorkFlowRecordCls=WorkflowBll.CreateWorkFlowRecord(oSiteParam.ConnectionString, WorkflowActionId);

                ParamPreviewFromWorkflowCls oParamPreviewFromWorkflowCls = new ParamPreviewFromWorkflowCls();
                oParamPreviewFromWorkflowCls.SiteId = SiteId;
                oParamPreviewFromWorkflowCls.RecordId = oWorkFlowRecordCls.RecordId;
                oParamPreviewFromWorkflowCls.WorkflowActionId = WorkflowActionId;
                oParamPreviewFromWorkflowCls.WorkflowDefId = oWorkFlowRecordCls.WorkFlowDefId;

                string PreviewUrl = oWorkFlowRecordCls.PreviewUrl;
                string TempUrl = PlugInViewFromWorkflowUtilities.GetPreviewUrl(oSiteParam.DllPath, oWorkFlowRecordCls.ExtraInfo, oParamPreviewFromWorkflowCls);
                if (string.IsNullOrEmpty(TempUrl) == false)
                {
                    PreviewUrl = TempUrl;
                }
                return PreviewUrl;
            }
            catch (Exception ex)
            {
                return "ERROR: " + ex.Message.ToString();
            }
        }


        class TempUserCls
        {
            public string LoginName;
            public bool IsTo = true;
        }
        
        //string GetHtml(
        //    string SiteId,
        //    string WorkflowDefId,
        //    string WorkflowActionId,
        //    string RecordId, 
        //    string ExtraInfo,
        //    string SelectedLinkId)
        //{

        //    try
        //    {
        //        WebSessionUtility.CheckSessionTimeOut();
        //        SiteParam oSiteParam = WebEnvironments.CreateSiteParam(SiteId);
        //        string Html = "";
        //        string LoginName = WebSessionUtility.GetCurrentLoginUser().LoginName;
        //        string CurrentLoginOffice = WebSessionUtility.GetCurrentLoginUser().AssetCode;
                
        //        string SelectLinkText=
        //            "<select id=\"drpSelectLink\" style=\"width:100%\" onchange=\"javascript:ClientSelectNextLink('" + WorkflowDefId + "','" + WorkflowActionId + "','" + RecordId + "');\">\r\n";
        //        DataTable dtNextLinks = new WorkflowBll().GetNextLinks(oSiteParam.DllPath, oSiteParam.ConnectionString, WorkflowActionId, LoginName, CurrentLoginOffice);
        //        DataView dvLinks = new DataView(dtNextLinks, "", "SortIndex ASC", DataViewRowState.CurrentRows);
        //        SelectLinkText += "<option>== Chọn đường xử lý ==</option>\r\n";
        //        int SelectUser = 0;
        //        for (int iIndex = 0; iIndex < dvLinks.Count; iIndex++)
        //        {
        //            string LinkId = (string)dvLinks[iIndex]["LinkId"];
        //            string LinkName = (string)dvLinks[iIndex]["LinkName"];
        //            if (SelectedLinkId.Equals(LinkId))
        //            {
        //                SelectLinkText += "<option selected value=\"" + LinkId + "\">" + LinkName + "</option>\r\n";
        //                SelectUser = int.Parse(dvLinks[iIndex]["SelectUser"].ToString());
        //            }
        //            else
        //            {
        //                SelectLinkText += "<option value=\"" + LinkId + "\">" + LinkName + "</option>\r\n";
        //            }
        //        }

        //        SelectLinkText += "</select>";

        //        string WorkflowImageButton = "";
        //        string PngFile=WorkflowDefId + ".png";
        //        string PicFile = oSiteParam.PathRoot + "\\Images\\Workflows\\" + PngFile;
        //        if (File.Exists(PicFile))
        //        {
        //            WorkflowImageButton = "<input  value=\"Thuộc quy trình\" type=\"button\" class=\"button\" onclick=\"javascript:window.open('"+oSiteParam.HttpRoot+"/Images/Workflows/" + PngFile + "','_blank');\">";
        //        }
        //        string ButtonSelectLink = "";
        //        Html =
        //                 "<input type=\"hidden\" id=\"txtWorkflowActionId\" value=\"" + WorkflowActionId + "\">\r\n" +
        //                 "<input type=\"hidden\" id=\"txtWorkflowDefId\" value=\"" + WorkflowDefId + "\">\r\n" +
        //                 "<input type=\"hidden\" id=\"txtRecordId\" value=\"" + RecordId + "\">\r\n" +
        //                 "<div class=tabcontent>\r\n" +
        //                 "<table class=CssTableWorkflow>" +
        //                 "  <tr>" +
        //                 "      <td class=Col1>Chọn xử lý</td>" +
        //                 "      <td class=Col2>" + SelectLinkText + "</td>" +
        //                 "      <td class=Col3>" + ButtonSelectLink + "<input value=\"Thực hiện xử lý\" class=\"button\" type=\"button\" onclick=\"javascript:ClientDoNextLink();\"><input value=\"Hủy xử lý\" class=\"button\" type=\"button\" onclick=\"javascript:ClientCancelDoNextLink();\">" + WorkflowImageButton + "</td>" +//<input value=\"Xem tài liệu gốc\" class=\"button\" type=\"button\" onclick=\"javascript:ClientShowOriginDocument('" + WorkflowActionId + "');\">
        //                 "  </tr>" +
        //                 "</table>" +
        //                 "</div>\r\n" +
        //                 "<div id=divContentWorkflowProcess>\r\n" +
        //                 "<table>\r\n" +
        //                 "  <tr>\r\n" +
        //                 "      <td valign=top class=WfCol1>\r\n";

        //        string ToUsers = "";
        //        string ViewUsers = ""; 
        //        if (String.IsNullOrEmpty(SelectedLinkId) == false)
        //        {
        //            string DllPath = oSiteParam.DllPath;
        //            Html += ServerSideDetectUsers(SiteId, WorkflowDefId, WorkflowActionId, RecordId, SelectedLinkId).ReturnMsg;
        //            ToUsers = new WorkflowBll().ServerSideGetToUsersByFullName(DllPath, oSiteParam.ConnectionString, WorkflowDefId, WorkflowActionId, SelectedLinkId);
        //            ViewUsers = new WorkflowBll().ServerSideGetViewUsersByFullName(DllPath, oSiteParam.ConnectionString, WorkflowDefId, SelectedLinkId);

        //        }


        //        Hashtable hs = new Hashtable();
        //        string[] ArrToUsers = ToUsers.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
        //        string[] ArrViewUsers = ViewUsers.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
        //        Collection<TempUserCls> TempUsers = new Collection<TempUserCls> { };
        //        for (int iIndex = 0; iIndex < ArrToUsers.Length; iIndex++)
        //        {
        //            string ItemLoginName = ArrToUsers[iIndex].Trim();
        //            if (hs.ContainsKey(ItemLoginName) == false)
        //            {
        //                hs.Add(ItemLoginName, null);
        //                TempUserCls oTempUserCls = new TempUserCls();
        //                oTempUserCls.IsTo = true;
        //                oTempUserCls.LoginName = ItemLoginName;

        //                TempUsers.Add(oTempUserCls);
        //            }
        //        }
        //        //doan nay add vao view user...!
        //        for (int iIndex = 0; iIndex < ArrViewUsers.Length; iIndex++)
        //        {
        //            string ItemLoginName = ArrViewUsers[iIndex].Trim();
        //            if (hs.ContainsKey(ItemLoginName) == false)
        //            {
        //                hs.Add(ItemLoginName, null);
        //                TempUserCls oTempUserCls = new TempUserCls();
        //                oTempUserCls.IsTo = false;
        //                oTempUserCls.LoginName = ArrViewUsers[iIndex].Trim();
        //                TempUsers.Add(oTempUserCls);
        //            }
        //        }

        //        string AppendStyle = " style=\"display:none;\" ";

        //        string ToCheckedText = "";
        //        string ViewCheckedText = "";
        //        string TableSelectUserHtml = "";
        //        bool ShowPreviewUser = false;
        //        if (String.IsNullOrEmpty(SelectedLinkId) == false)
        //        {
        //            TableSelectUserHtml =
        //                                     "<table>\r\n" +
        //                                     "  <tr>\r\n" +
        //                                     "      <th  align=center>Đến</th>\r\n";
        //            if (ShowPreviewUser)
        //            {
        //                TableSelectUserHtml +=
        //                                     "      <th  align=center>P</th>\r\n";
        //            }
        //            if (ShowPreviewUser)
        //            {
        //                TableSelectUserHtml +=
        //                                     "      <th  align=center></th>\r\n";
        //            }
        //            TableSelectUserHtml+=
        //                                     "  </tr>\r\n" +
        //                                     "  <tr>\r\n" +
        //                                     "      <th align=center><input id=chkAllToUser type=checkbox onchange=\"javascript:ClientProcessToAllUser();\"></th>\r\n";
        //            if (ShowPreviewUser)
        //            {
        //                TableSelectUserHtml +=
        //                                     "      <th align=center> <input id=chkAllRelUser type=checkbox onchange=\"javascript:ClientProcessRelAllUser();\"></th>\r\n";
        //            }
        //            TableSelectUserHtml +=
        //                                     //"      <th><input id=chkAllViewUser type=checkbox></th>\r\n" +
        //                                     "      <th align=center></th>\r\n" +
        //                                     "  </tr>\r\n";

        //            string ToUserText = "";
        //            for (int iIndex = 0; iIndex < TempUsers.Count; iIndex++)
        //            {
        //                string ToChecked = "";
        //                string RelChecked = "";
        //                //string ViewChecked = "";
                        
        //                string ToId = System.Guid.NewGuid().ToString().Substring(0, 8);
        //                string RelId = System.Guid.NewGuid().ToString().Substring(0, 8);
        //                string ViewId = System.Guid.NewGuid().ToString().Substring(0, 8);
        //                if (TempUsers[iIndex].IsTo)
        //                {
        //                    ToChecked = " checked ";
        //                }
        //                else
        //                {
        //                    RelChecked = " checked ";
        //                }
        //                ToCheckedText = ToCheckedText + "chk" + ToId + ";";
        //                ViewCheckedText = ViewCheckedText + "chk" + RelId + ";";
        //                TableSelectUserHtml += "  <tr>\r\n" +
        //                                       "      <td align=center><input id=\"chk" + ToId + "\" type=checkbox " + ToChecked + " onchange=\"javascript:ClientProcessToUser('" + TempUsers[iIndex].LoginName + "','chk" + ToId + "');\"></td>\r\n";
        //                if (ShowPreviewUser)
        //                {
        //                    TableSelectUserHtml +=
        //                                       "      <td align=center><input id=\"chk" + RelId + "\" type=checkbox " + RelChecked + " onchange=\"javascript:ClientProcessViewUser('" + TempUsers[iIndex].LoginName + "','chk" + RelId + "');\"></td>\r\n";
        //                }
        //                TableSelectUserHtml+=
        //                                       //"      <td align=center><input id=\"chk" + ViewId + "\" type=checkbox \"></td>\r\n" +
        //                                       "      <td>" + TempUsers[iIndex].LoginName + "</td>\r\n" +
        //                                       "  </tr>\r\n";
        //                ToUserText = ToUserText + TempUsers[iIndex].LoginName + "; ";
        //            }
        //            TableSelectUserHtml += "</table>\r\n";

        //            if (TempUsers.Count > 0)
        //            {
        //                AppendStyle = " ";
        //            }
        //            else
        //            {
        //                TableSelectUserHtml = "";
        //            }
        //        }
        //        Html += "</td>\r\n";
        //        if (SelectUser == 1)
        //        {
        //            Html +=
        //               "<td valign=top class=WfCol2>\r\n" +
        //               "    <div class=CssWorkflowUser " + AppendStyle + ">\r\n" +
        //               "        <input type=hidden id=txtToCheckedText value=\"" + ToCheckedText + "\">" +
        //               "        <input type=hidden id=txtViewCheckedText value=\"" + ViewCheckedText + "\">" +
        //                         TableSelectUserHtml + "\r\n" +
        //               "    </div>\r\n" +
        //               " </td>\r\n";
        //        }
        //        Html+=
        //               "</tr>\r\n"+
        //               "</table>\r\n"+
        //               "</div>\r\n";
        //        string AttachedDocumentText = WorkflowBll.ServerSideGetPlugInAttachedFileHtml(oSiteParam.ConnectionString, WorkflowActionId, true);
        //        if (string.IsNullOrEmpty(AttachedDocumentText) == false)
        //        {
        //            Html +=
        //                AttachedDocumentText;
        //        }
        //        return Html;
        //    }
        //    catch (Exception ex)
        //    {
        //        return "ERROR: "+ex.Message.ToString();
        //    }
        //}

        [AjaxPro.AjaxMethod]
        public string GetConfirmMsg(string SiteId)
        {
            return "Bạn đã chắc chắn xóa chưa?";
        }

        [AjaxPro.AjaxMethod]
        public string ServerSideRemoveFile(string SiteId, string SessionId, string FileName)
        {
            try
            {
                WebSessionUtility.CheckSessionTimeOut();
                SiteParam oSiteParam = WebEnvironments.CreateSiteParam(SiteId);
                string DeleteFileName = oSiteParam.PathRoot + "\\media\\" + oSiteParam.SiteId + "\\TempUploadFiles\\" + SessionId + "\\" + FileName;
                new System.IO.FileInfo(DeleteFileName).Delete();
                return "Loại bỏ tài liệu gắn kèm thành công!";
            }
            catch (Exception ex)
            {
                return "ERROR: " + ex.Message.ToString();
            }
        }

        //[AjaxPro.AjaxMethod]
        //public string ServerSideGetUploadFileUrl(string SiteId, string ParentControlId, string SessionId)
        //{
        //    return Screen.BuildDialogUrl(
        //        SiteId,
        //        "WorkflowUploadFiles",
        //        new ParamCls[]{
        //            new ParamCls("ParentControlId",ParentControlId),
        //            new ParamCls("SessionId",SessionId),
        //    });
        //}


        //[AjaxPro.AjaxMethod]
        //public string ServerSideSelectResponsible(
        //    string SiteId, 
        //    string ParentId,
        //    string ParentIdText)
        //{
        //    return Screen.BuildDialogUrl(
        //        SiteId,
        //        "SelectResponsible",
        //        new ParamCls[]{
        //            new ParamCls("ParentId",ParentId),
        //            new ParamCls("ParentIdText",ParentIdText),
        //    });
        //}

        [AjaxPro.AjaxMethod]
        public ReturnParamCls ServerSideProcessUser(string SiteId, string UserIds, string LoginName, bool Checked)
        {
            ReturnParamCls oReturnParamCls = new ReturnParamCls();
            try
            {
                string[] AllUsers = UserIds.Split(new char[] { ';',','},StringSplitOptions.RemoveEmptyEntries);
                string UserText="";
                if (Checked == false)
                {
                    //remove no di
                    for (int iIndex = 0; iIndex < AllUsers.Length; iIndex++)
                    {
                        if (!AllUsers[iIndex].Trim().ToLower().Equals(LoginName.Trim().ToLower()))
                        {
                            if (string.IsNullOrEmpty(UserText) == false)
                            {
                                UserText += "; ";
                            }
                            UserText = UserText + AllUsers[iIndex].Trim();
                        }
                    }
                }
                else
                {
                    //doan nay can them vao kiem tra xem no co chua. neu co roi thi thoi
                    bool Found = false;
                    for (int iIndex = 0; iIndex < AllUsers.Length; iIndex++)
                    {
                        if (AllUsers[iIndex].Trim().ToLower().Equals(LoginName.Trim().ToLower()))
                        {
                            Found = true;
                        }
                        if (string.IsNullOrEmpty(UserText) == false)
                        {
                            UserText += "; ";
                        }
                        UserText = UserText + AllUsers[iIndex].Trim();
                    }
                    if (!Found)
                    {
                        if (string.IsNullOrEmpty(UserText) == false)
                        {
                            UserText += "; ";
                        }
                        UserText = UserText + LoginName.Trim();
                    }
                }

                UserText = UserText.Trim();
                oReturnParamCls.HtmlContent = UserText;
            }
            catch (Exception ex)
            {
                oReturnParamCls.IsError = true;
                oReturnParamCls.HtmlContent = ex.Message.ToString();
            }
            return oReturnParamCls;
        }
        
    }
}
